from django.db import models
import time


class Commits(models.Model):
    """
    User's valid register commits.
    """
    # Primary key.
    id = models.BigAutoField(primary_key=True)
    # Server's time of commit data to database.
    time = models.FloatField(default=time.time)
    # User's IP address.
    ip = models.CharField(max_length=200)
    # JSON string of user's commit data.
    options = models.TextField()


class Options(models.Model):
    """
    Options that user should complete.
    """
    # Primary key.
    id = models.BigAutoField(primary_key=True)
    # Order of options.
    seq = models.BigIntegerField()
    # Display name of this option.
    name = models.CharField(max_length=200)
    # Key name of this option.
    key = models.CharField(max_length=200)
    # Does user must complete this option?
    # | True | False |
    must = models.BooleanField()
    # Type of value.
    # | string | ...
    type = models.CharField(max_length=200)
    # Input widget that front end should use.
    # | text | ...
    widget = models.CharField(max_length=200)
    # Method to validate value.
    # | none | ...
    checkMethod = models.CharField(max_length=200)
